public class Test5 {
    static Object locker =new Object();
    static Object locker2 =new Object();

    public static void main(String[] args) {
        Thread t1=new Thread(()->{
           synchronized (locker){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               synchronized (locker2){
                   System.out.println(" t1 加锁完成");
               }
           }
        });
        Thread t2=new Thread(()->{
            synchronized (locker2){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker){
                    System.out.println(" t2 加锁完成");
                }
            }
        });

        t1.start();
        t2.start();
    }
}
